<!--面试考核-->
<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane :label="item.name" :name="item.id" v-for="item in tabList" :key="item.id"></el-tab-pane>
      </el-tabs>
      <!--本体列表，数据 -->
      <personality v-if="activeName==1"></personality>
      <learning_quality v-if="activeName==4"></learning_quality>
    </div>
  </div>
</template>

<script>
import {pagination, tableoption, yeartime} from '@/utils/util.js'
import personality from "./component/personality";
import learning_quality from "./component/learning_quality";
export default {
  components: {
    personality,
    learning_quality
  },
  data() {
    return {
      tableList: [{name: '全部', id: 0}],
      tableoption: tableoption,
      autosize: {minRows: 2, maxRows: 4},
      tabList: [
        {
          name: '九型人格',
          id: '1'
        },
        // {
        //   name: '个性发展',
        //   id: '2',
        // },
        // {
        //   name: '亲子背景',
        //   id: '3'
        // },
        {
          name: '学习品质',
          id: '4'
        },
        // {
        //   name: '专注力',
        //   id: '5'
        // }
      ],
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      first_id: '',
      arryList: [], // 数据列表
      // 搜索
      searchWord: '',
      searchCatId: 0,
      // 弹窗
      dialogVisible: false,
      editIndex: null,
      foodOption: '',
      dialogType: null,
      activeName: '1',
      searchForm: {
        job_id: '',
        name: ''
      },
      jobList: []
    }
  },
  created() {
    this.InitFn()
  },
  methods: {
    // 初始化
    async InitFn() {
      let data = await this.$fetch(this.api.acquisition.setting.personality, {p: 1});
      console.log('data:', data)
      if (!data.code) {
        for (let item of data.list.data) {
          item.eidt = false
        }
        this.arryList = data.list.data
        this.page.total = data.list.total
      }
    },
    showEditFn(row, index) {
      let option = this.getJson(row)
      if (option.edit) {
        this.editTitle(option)
      } else {
        option.edit = true;
      }
      this.$set(this.arryList, index, option)
    },
    async editTitle(option) {
      let option_ = {
        id: option.id, // 	整型 	必填 	1 	- 	ID
        title: option.title, 	// 整型 	必填 	1 	- 	内容
        character_id: option.character_id, 	// 整型 	必填 	1 	- 	对应人格id
        user_title: option.user_title,
        parent_title: option.parent_title
      }
      let data = await this.$post(this.api.acquisition.setting.edit_personality, option_);
      if (!data.code) {
        option.edit = false;
      }
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    cateListFn() {
      this.$fetch(this.api.cate_list, {
        p: 1
      }).then((response) => {
        if (response.code === 0) {
          for (let i in response.list.data) {
            this.tableList.push(response.list.data[i])
          }
        } else {
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    showDetail(id) {
      this.resumeId = id
      this.resumeVisible = true
    },
    handleClick(tab, event) {
      if (this.activeName !== this.activeNamechange) {
        this.activeNamechange = this.activeName;
        this.page.pageindex = 1
        this.arryList = []
        this.InitFn()
      }
    },
    // 获取岗位信息
    async JobFn() {
      let data = await this.$fetch(this.api.recruit.job.index, {p: 1});
      this.jobList = data.list.data;
    },
    searchFn(option) {
      if (option === 'refresh') {
        this.searchForm.name = ''
        this.searchForm.job_id = ''
      }
      this.page.pageindex = 1;
      this.InitFn()
    }
  },
  mounted() {
  }
}
</script>
<style>
.not-list {
  text-align: center;
  padding: 50px;
  color: #999;
  font-size: 16px;
}
</style>
